<extend name="template/base_index" />

<block name="area_header">
    <meta name="format-detection" content="telephone=no" />
    <link rel="stylesheet" href="__CSS__/addre_manage.css">
</block>

<block name="area_body">
    <div class="addre_mhead">
        <a href ="{:U('UserCenter/index')}"><i class="fa fa-chevron-left"></i></a>
    </div>
    <div class="main_content">
    <volist name="addr" id="vo">
        <div class="weui_cells mr_dz">
            <div class="weui_cell buy_addre">
                <div class="buy_addre">
                    <div class="buy_shr"><span>收货人：{$vo['contactname']}</span><span class="buy_tel">{$vo['mobile']}</span></div>
                    <div class="buy_dzx"><span class="buy_nrd">收货地址：</span><div class="buy_rdz">{$vo['province']}{$vo['city']}{$vo['area']}{$vo['detailinfo']}</div></div>
                </div>
            </div>
            <div class="weui_cell">
                <div class="weui_cell_hd">
                    <if condition="$d_addr == $vo['id']">
                        <span class="addre_default"><i class="fa fa-check-circle-o"></i>默认地址</span>
                        <else />
                        <a alt="{$vo['id']}" class="set_addre"><i class="fa fa-circle-o"></i>默认地址</a>
                    </if>
                </div>
                <div class="weui_cell_bd weui_cell_primary">
                    <a class="addre_delet"  alt="{$vo['id']}"><i class="fa fa-trash"></i>删除</a>
                    <a class="addre_edit" href="{:U('Address/addre_edit',array('id'=>$vo['id']))}"><i class="fa fa-pencil-square-o"></i>编辑</a>
                </div>
            </div>
        </div>
    </volist>
    </div>
        <center><a href="{:U('Address/add_addre')}" class="sure-button">新增地址</a></center>
        <span id="res"></span>
    <script src="__JS__/jquery-weui.min.js"></script>
    <script type="text/javascript">
        $(function(){
            $(".addre_delet").bind("click", function() {
                var id = $(this).attr('alt');
                $.confirm("您确定要删除该地址吗?", "确认删除?", function() {
                    $.get("{:U('Address/addre_delete')}",{id:id},function(res){
                                if(res){
                                    $.toast("地址删除成功!");
                                    location.reload();
                                }else{
                                    $.toast("地址删除失败!");
                                }
                            }
                    );
                }, function() {
                    //取消操作
                });
            });
            $(".set_addre").bind("click", function() {
                var id = $(this).attr('alt');
                $.confirm("您确定要设置该地址为默认地址?", "确认", function() {
                    $.get("{:U('Address/set_addre')}",{id:id},function(res){
                                if(res){
                                    $.toast('设置成功');
                                    location.reload();
                                }else{
                                    $.toast('设置失败');
                                }
                            }
                    );
                }, function() {
                    //取消操作
                });
            });
        });
    </script>
</block>